#include "nlohmann/json.hpp"
#include "protocol_init.h"
#include "base_noncopyable.h"
#include "web_server.h"
#include "base_block_queue.h"
#include <thread>
#include <atomic>

namespace El {
namespace Protocol {

class ProtocolManager {
    DISALLOW_COPY_AND_MOVE(ProtocolManager);

public:
    static ProtocolManager &GetInstance();

    bool Start();
    void Stop();

private:
    ProtocolManager() = default;
    ~ProtocolManager();

    void HandleWebSocketEvent(std::shared_ptr<El::WebServer::WebSocketEvent> &event);
    void ProcessWebSocketEvents();

    std::unique_ptr<El::Base::BlockingQueue<std::shared_ptr<El::WebServer::WebSocketEvent>>> event_queue_{nullptr};
    std::unique_ptr<std::thread> process_thread_{nullptr};
    std::atomic<bool> running_{false};
};
} // namespace Protocol
} // namespace El
